package com.example.experiment2.service.Impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.experiment2.entity.Grade;
import com.example.experiment2.mapper.GradeMapper;
import com.example.experiment2.service.GradeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class GradeServiceImpl implements GradeService {
    @Resource
   public  GradeMapper gradeMapper;
    @Override
    public List<Grade> listAll() {
        return gradeMapper.selectList(null);
    }
    @Override
    public List<Grade> getByCourseId(int courseId) {
        return gradeMapper.selectList(new QueryWrapper<Grade>().eq("course_id", courseId));
    }
    @Override
    public void update(Grade grade) {
        gradeMapper.updateById(grade);
    }
    @Override
    public List<Grade> getByScoreRange(int minScore, int maxScore) {
        return gradeMapper.selectList(new QueryWrapper<Grade>().between("score", minScore, maxScore));
    }
    @Override
    public void updategrade(Grade grade) {
        gradeMapper.updateById(grade);
    }
    @Override
    public List<Grade> getGradesByStudentId(int student_id) {
        return gradeMapper.selectList(new QueryWrapper<Grade>().eq("student_id",student_id));
    }
}